function searchSalesPrice() {
    var form = document.getElementById('form');
    document.getElementById("sort").value = "salesPrice";
    var status = document.getElementById("status");
    console.log(document.getElementById("salesPrice").value);
    status.value = document.getElementById("salesPrice").value;
    form.submit();
}

function searchMeta() {
    var form = document.getElementById('form');
    document.getElementById("sort").value = "meta";
    var status = document.getElementById("status");
    status.value = document.getElementById("meta").value;
    form.submit();
}

function searchSalesVolume() {
    var form = document.getElementById('form');
    document.getElementById("sort").value = "salesVolume";
    var status = document.getElementById("status");
    status.value = document.getElementById("salesVolume").value;
    form.submit();
}

function searchId() {
    var form = document.getElementById('form');
    document.getElementById("sort").value = "id";
    var status = document.getElementById("status");
    status.value = document.getElementById("id").value;
    form.submit();
}

function searchType(obj) {
    var form = document.getElementById('form');
    document.getElementById("sort").value = "";
    document.getElementById("status").value = "";
    document.getElementById("keyword").value = "";
    document.getElementById("type").value = obj.id;
    document.getElementById("pageNum").value = "1";
    form.submit();
}

function searchGood() {
    //var searchkeyword = $('input[name=searchkeyword]').val();
    var searchkeyword=document.getElementById("searchKeyword").value
    console.log(searchkeyword);
    if (keyword !== "") {
        var form = document.getElementById('form');
        document.getElementById("keyword").value = searchkeyword;
        document.getElementById("sort").value = "";
        document.getElementById("status").value = "";
        document.getElementById("type").value = "";
        document.getElementById("pageNum").value = "1";
        form.submit();
    }
}
function firstPage(){
    var form = document.getElementById('form');
    document.getElementById("pageNum").value = "1";
    form.submit();
}
function lastPage(){
    var form = document.getElementById('form');
    document.getElementById("pageNum").value = document.getElementById("totalPages").value;
    console.log( document.getElementById("pageNum").value);
    console.log( document.getElementById("totalPages").value);
    form.submit();
}
function nextPage(){
    var form = document.getElementById('form');
    var totalPages=document.getElementById("totalPages");
    var pageNum=document.getElementById("pageNum");
    pageNum.value=parseInt(pageNum.value)+1;
    if(pageNum.value>=totalPages.value)
        pageNum.value=totalPages.value;
        form.submit();
}
function prePage(){
    var form = document.getElementById('form');
    var pageNum=document.getElementById("pageNum");
    pageNum.value=pageNum.value-1;
    if(pageNum.value<=0)
        pageNum.value=1;
        form.submit();
}
function searchPage(){
    var form = document.getElementById('form');
    var pageNum=document.getElementById("searchPageNum");
    var totalPages=document.getElementById("totalPages").value;
    if (pageNum.value>totalPages)
        pageNum.value=totalPages;
    if(pageNum.value<=0)
        pageNum.value=1;
    document.getElementById("pageNum").value=pageNum.value;
    form.submit();
}
function updateAccount(id){
    var form=document.getElementById("form");
    var input = document.createElement("input");
    input.setAttribute("type",'hidden') ;
    input.setAttribute("name",'accountId') ;
    input.setAttribute("value", id) ;
    form.appendChild(input);
    console.log(input);
    form.action="/admin/account"
    form.submit();
}
function ableUpdate(obj){
    document.getElementById(obj.id).innerHTML="保存"
    document.getElementById("pay"+obj.id).disabled="";
    document.getElementById("login"+obj.id).disabled="";
    document.getElementById(obj.id).onclick = function(){
        updateAccount(obj.id);
    };

}